import requests
import execjs
cookies = {
    'PHPSESSID': 'hcbu72k5l3ljleqoc8u71qv11d',
    'Hm_lvt_6cd598ca665714ffcd8aca3aafc5e0dc': '1698646148',
    'Hm_lpvt_6cd598ca665714ffcd8aca3aafc5e0dc': '1698649870',
    'SECKEY_ABVK': '40pNVlvYo8aUAWydp1FTRD/Dqo1p2B60Mcxmn1Qagf4%3D',
    'BMAP_SECKEY': 'Nv30_vf4gHbQVeCM5H43OYN00VL1sxIC7o5R-r6ge9nh34HN4gJSCajRAQrU0iEmgUklNDB0tl8mA4nMOwVeqqGT6jDmLzox2DgWz0dSLMD0IesaQzv4QMjcaec_cGQHuF2FH-QXckn6VRdVoPdkdE1tVpn0aAnl_5tWJEZvHTrmLO1spRb9YSkqBlmyfbc5',
}

headers = {
    'Accept': '*/*',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Connection': 'keep-alive',
    'Content-Type': 'application/json; charset=UTF-8',
    # 'Cookie': 'PHPSESSID=hcbu72k5l3ljleqoc8u71qv11d; Hm_lvt_6cd598ca665714ffcd8aca3aafc5e0dc=1698646148; Hm_lpvt_6cd598ca665714ffcd8aca3aafc5e0dc=1698649870; SECKEY_ABVK=40pNVlvYo8aUAWydp1FTRD/Dqo1p2B60Mcxmn1Qagf4%3D; BMAP_SECKEY=Nv30_vf4gHbQVeCM5H43OYN00VL1sxIC7o5R-r6ge9nh34HN4gJSCajRAQrU0iEmgUklNDB0tl8mA4nMOwVeqqGT6jDmLzox2DgWz0dSLMD0IesaQzv4QMjcaec_cGQHuF2FH-QXckn6VRdVoPdkdE1tVpn0aAnl_5tWJEZvHTrmLO1spRb9YSkqBlmyfbc5',
    'Origin': 'https://www.maomaozu.com',
    'Referer': 'https://www.maomaozu.com/',
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'same-origin',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36',
    'sec-ch-ua': '"Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
}
# 引入js
js_file = open('毛毛租解析JS.js', 'r', encoding='utf-8').read()
# 调用js中的方法，传入页数
data = execjs.compile(js_file).call('request_param',2)

# 请求获取数据
response = requests.post('https://www.maomaozu.com/index/build.json', cookies=cookies, headers=headers, data=data)

# 调用js 解析返回数据
result_data = execjs.compile(js_file).call('response_data',response.text)

# 遍历解析后的json数据
for item in result_data['list']:
    print(item)

